package main

import (
	"fmt"
	"os"
	"bufio"
	"io"
)

func main(){
	file_path,_ := os.Getwd()
	file_url := file_path + "/Test.txt"

	//打开文件
	file,open_err := os.Open(file_url)

	if open_err != nil{
		fmt.Println("文件打开失败：",open_err)
	}

	defer file.Close()

	//读取文件流
	content := bufio.NewReader(file)
	
	for{
		//循环读取每行数据
		str,str_err := content.ReadString('\n')

		if str_err == io.EOF{
			break
		}

		if str_err != nil{
			fmt.Println("读取失败：",str_err)
		}

		fmt.Println(str)
	}

	fmt.Println("文件读取成功")
}